home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- *
- * NSSDC/CDF Windowing functions.
- *
- * Version 2.0, 29-Feb-92, ST Systems (STX)
- *
- * Modification history:
- *
- * V1.0 29-Jan-91, H Leckner Original version (for CDF V2.0).
- * V1.1 4-Aug-91, J Love TRUE/FALSE. Minor change to borders (well
- * H Leckner maybe).
- * V1.2 13-Aug-91, H Leckner Fixed border labeling.
- * V1.3 8-Oct-91, J Love Modified for IRIX 4.0 port, etc.
- * H Leckner
- * V2.0 29-Feb-92, H Leckner CDF V2.2. IBM PC port.
- *
- ******************************************************************************/
-
- #ifdef vms
- #include <stdio.h>
- #include <descrip.h>
- /*
- * MODULE: SMG_GLUE_C.C
- */
-
- #define KEYPADBUG (0)
-
- #include <smgdef.h>
- #include <ssdef.h>
-
- /*CodeRef-mark*/
-
- /* Additions to SMG_GLUE_C.C --
- * Set- and Get- physical cursor added, Dan Grogan, October 1988.
- */
- /*CodeRef-mark*/
-
- /*CodeRef-mark*/
- long int pbid;
- long int kbid;
- long get_physical_cursor (row, col)
-
- long int *row;
- long int *col;
- {
- /*CodeRef-mark*/
- long int status;
- long int smg$get_physical_cursor();
- status = smg$get_physical_cursor (&pbid, row, col);
- }
-
- /*CodeRef-mark*/
- long set_physical_cursor (row, col)
- long int row;
- long int col;
- {
- /*CodeRef-mark*/
- long int status;
- long int smg$set_physical_cursor();
- status = smg$set_physical_cursor (&pbid, &row, &col);
- }
-
-
- create_virtual_display ( num_rows, num_cols, vid, disp_type, video_type )
- long int num_rows;
- long int num_cols;
- long int *vid;
- long int disp_type;
- long int video_type;
- {
- long int status;
- long int smg$create_virtual_display();
- status = smg$create_virtual_display (&num_rows, &num_cols,
- vid, &disp_type, &video_type);
- }
- delete_virtual_display ( vid )
- long int vid;
- {
- long int status;
- long int smg$delete_virtual_display();
-
- status = smg$delete_virtual_display ( &vid );
- }
-
- change_virtual_display ( num_rows, num_cols, vid, disp_type, video_type )
- long int num_rows;
- long int num_cols;
- long int vid;
- long int disp_type;
- long int video_type;
- {
- long int status;
- long int smg$change_virtual_display();
-
- status = smg$change_virtual_display (&vid, &num_rows, &num_cols,
- &disp_type, &video_type);
- }
-
- begin_pasteboard_update()
- {
- long int status;
- long int smg$begin_pasteboard_update();
-
- status = smg$begin_pasteboard_update(&pbid);
- }
- end_pasteboard_update()
- {
- long int status;
- long int smg$end_pasteboard_update();
-
- status = smg$end_pasteboard_update(&pbid);
- }
-
-
- paste_virtual_display(vid, row, col)
- long int vid;
- long int row;
- long int col;
- {
- long int status;
- long int smg$paste_virtual_display();
- status = smg$paste_virtual_display(&vid, &pbid, &row, &col);
- /* if(status != SS$_NORMAL)lib$signal(status);*/
-
- }
- unpaste_virtual_display(vid)
- long int vid;
- {
- long int status;
- long int smg$unpaste_virtual_display();
-
- status = smg$unpaste_virtual_display(&vid, &pbid);
- }
- change_rendition ( vid, row, col, num_rows, num_cols, on_or_off)
- long int vid;
- long int row;
- long int col;
- long int num_rows;
- long int num_cols;
- long int on_or_off;
- {
- long int status;
- long int smg$change_rendition();
- status = smg$change_rendition (&vid, &row, &col,
- &num_rows, &num_cols, &on_or_off);
- }
- return_cursor_pos ( vid, row, col)
- long int vid;
- long int *row;
- long int *col;
- {
- long int status;
- long int smg$return_cursor_pos();
- status = smg$return_cursor_pos (&vid, row, col);
- }
- set_cursor_abs ( vid, row, col)
- long int vid;
- long int row;
- long int col;
- {
- long int status;
- long int smg$set_cursor_abs();
- status = smg$set_cursor_abs (&vid, &row, &col);
- }
- set_cursor_rel ( vid, num_rows, num_cols)
- long int vid;
- long int num_rows;
- long int num_cols;
- {
- long int status;
- long int smg$set_cursor_rel();
- status = smg$set_cursor_rel (&vid, &num_rows, &num_cols);
- }
- repaint_screen()
- {
- long int status;
- long int smg$repaint_screen();
-
- status = smg$repaint_screen(&pbid);
- }
- delete_pasteboard(erase)
- long int erase;
- {
- long int status;
- long int smg$delete_pasteboard();
-
- status = smg$delete_pasteboard(&pbid, &erase);
- }
-
- ring_bell (vid)
- long int vid;
- {
- long int status;
- long int smg$ring_bell();
-
- status = smg$ring_bell(&vid);
- }
-
-
- /*
- * <dan> new functions
- */
-
-
- long int set_cursor_mode (cursorMode)
- long int cursorMode;
- {
- /*
- * pbid is a pasteboard id.
- * cursorMode = 0 : cursor ON, visible.
- * = 1 : cursor OFF, invisible.
- */
- long int status;
- long int smg$set_cursor_mode();
-
- status = smg$set_cursor_mode (&pbid, &cursorMode);
- }
-
-
- long int scroll_display_area (vid)
-
- long int vid;
- {
- long int startRow = 1, startCol = 2;
- long int height = 3, width = 1, direction = SMG$M_DOWN,
- count = 1;
-
- long int status;
- long int smg$scroll_display_area();
-
- status = smg$scroll_display_area (&vid, &startRow, &startCol,
- &height, &width, &direction,
- &count);
- }
-
-
- long int erase_display (vid, startRow, startCol, endRow, endCol)
- long int vid, startRow, startCol, endRow, endCol;
-
- {
- long int status;
- status = smg$erase_display (&vid, &startRow, &startCol,
- &endRow, &endCol);
- }
-
-
- long int begin_display_update(vid)
- long int vid;
- {
- long int status;
- long int smg$begin_display_update();
-
- status = smg$begin_display_update(&vid);
- }
-
-
- long int end_display_update(vid)
- long int vid;
- {
- long int status;
- long int smg$end_display_update();
-
- status = smg$end_display_update(&vid);
- }
-
-
- long int set_keypad_mode (mode)
- long int mode;
- {
- long int status;
- long int smg$set_keypad_mode();
-
- /* mode 0 is numeric keypad; mode 1 is applications functions pad */
- status = smg$set_keypad_mode (&kbid, &mode);
-
-
- }
- put_chars(vdid, string, len, row, col, erase, video_type)
- long int vdid;
- char string[];
- long int len;
- long int row;
- long int col;
- long int erase;
- long int video_type;
- {
- long int status;
- static char temp[512];
- static $DESCRIPTOR(string_desc, temp);
-
- strcpy(temp, string);
- string_desc.dsc$w_length = len;
- status = smg$put_chars(&vdid, &string_desc, &row, &col, &erase, &video_type);
- }
- label_border(vdid, string, len)
- long int vdid;
- char string[];
- long int len;
- {
- static char temp[512];
- long int video_type = SMG$M_REVERSE;
- long int status;
- static $DESCRIPTOR(string_desc, temp);
-
- strcpy(temp, string);
- string_desc.dsc$w_length = len;
-
- status = smg$label_border(&vdid, &string_desc, NULL, NULL, &video_type);
- }
- create_pasteboard ()
- {
- long int tot_rows;
- long int tot_cols;
- long int clear_flags = 0;
- long int status;
- long int temp;
- status = smg$create_pasteboard(&temp, NULL, &tot_rows,
- 1 &tot_cols, &clear_flags);
- if(status != SS$_NORMAL)lib$signal(status);
- pbid = temp;
- status = smg$create_virtual_keyboard(&temp, NULL, NULL, NULL, NULL);
- if(status != SS$_NORMAL)lib$signal(status);
- kbid = temp;
- }
- read_input(tcode)
- long int *tcode;
- {
- short int temp_code;
- long int status;
-
- /*
- READ a character from the keyboard
- */
- status = smg$read_keystroke(&kbid, &temp_code, NULL, NULL, NULL, NULL, NULL);
- *tcode = temp_code;
- }
- read_display(vdid, row, string)
- long int vdid;
- long int row;
- char string[];
- {
- long int status;
- static char temp[80];
- long int len;
- long int i;
- static $DESCRIPTOR(string_desc, temp);
- for(i=0; i<80; i++)
- temp[i] = ' ';
- status=smg$read_from_display(&vdid, &string_desc, NULL, &row);
- strcpy(string, temp);
- }
- save_screen(save_id)
- long int *save_id;
- {
- long int status;
- long int smg$save_physical_screen();
- status = smg$save_physical_screen(&pbid, save_id);
- }
- restore_screen(save_id)
- long int save_id;
- {
- long int status;
- long int smg$restore_physical_screen();
- status = smg$restore_physical_screen(&pbid, &save_id);
- }
- ast_routine(pbid_arr)
- long int pbid_arr[];
- {
- static char message[512];
- long int pbid;
- long int message_vdid;
- short int mess_len;
- long int row, col;
- long int status;
- static $DESCRIPTOR(message_desc, message);
-
- pbid = pbid_arr[0];
- message_vdid = pbid_arr[1];
-
- status = smg$get_physical_cursor (&pbid, &row, &col);
- status = smg$get_broadcast_message(&pbid, &message_desc,&mess_len);
- status = smg$put_line(&message_vdid, &message_desc);
- status = smg$ring_bell(&message_vdid);
- status = smg$set_physical_cursor (&pbid, &row, &col);
- }
- enable_trap (mess_vid)
- long int mess_vid;
- {
- static long int pbid_arr[2];
-
- long int status;
- long int ast_routine();
-
- pbid_arr[0] = pbid;
- pbid_arr[1] = mess_vid;
-
- status = smg$set_broadcast_trapping(&pbid, ast_routine, pbid_arr);
- }
- #endif
-
- #if defined(unix) | defined(__MSDOS__)
- /*
- Replacement for VAX screen manager WFL glue layer
- Changes:
-
- put_chars: now in C therefore when it is called arguments should not be
- passed by value
- read_input: argument changed to long integer vdid for curses for the current
- window that is used to be read from (kbid is not used in curses
- */
- #include "window.h"
-
- /* #define A_NORMAL 0 TEST A_NORMAL is not in PCCURS14 */
- /* #define A_BOLD 0x4000 add to window.h ************/
- #define DUMMY 0
-
- /* Global variables (local to this source file). */
-
- static WINDOWid window_on_screen[100];
- static long num_window_on_screen;
-
- struct all_win_struct {
- WINDOWid window_id;
- int video_type;
- } static all_windows[100];
-
- static long num_windows;
- static long UPDATE_WINDOW;
-
-
- /** End of global variables. */
-
- void create_pasteboard ()
- {
- initscr();
- cbreak();
- noecho();
- wattrset(stdscr, A_NORMAL);
- UPDATE_WINDOW = TRUE;
- num_windows = 0;
- num_window_on_screen = 0;
- }
- #if 0 /*jtl*/
- void set_cursor_mode(pbid, mode)
- int pbid;
- int mode;
- {
- pbid = DUMMY;
- mode = DUMMY;
- /*curs_set(mode);*/
- }
- #endif /*jtl*/
-
- int window_attribute(window_id)
- WINDOWid window_id;
- {
- int i;
- for (i=0; i<num_windows; i++)
- {
- if(window_id == all_windows[i].window_id)return(all_windows[i].video_type);
- }
- return(NORMAL);
- }
- void put_chars(vdid, str, len, row, col, erase_line, video_type)
- WINDOWid vdid;
- char str[];
- int len;
- int row;
- int col;
- int erase_line;
- int video_type;
- {
- /*int status;*/
- char temp[512];
- int i /*,x,y*/ ;
- register WINDOWid vdp = vdid;
- register char *s;
- int maxx;
- #if defined(unix) | defined(__MSDOS__)
- maxx = vdp->_maxx;
- #else
- maxx = vdp->cols;
- #endif
-
- if(erase_line)
- {
- s = temp;
- for(i=0; i< maxx-2; i++)
- *s++ = ' ';
- *s = '\0';
- wattrset(vdp, A_NORMAL);
- mvwaddstr(vdp, row, 1, temp);
- }
-
-
- switch(video_type)
- {
- case NORMAL:
- case BOLD:
- if(window_attribute(vdp) == NORMAL)
- #if defined(__MSDOS__)
- wattrset(vdp, A_HIGH|F_BROWN|B_BLUE);
- #else
- wattrset(vdp, A_NORMAL);
- #endif
- else
- #if defined(__MSDOS__)
- wattrset(vdp, A_HIGH|F_GRAY|B_BLUE);
- #else
- wattrset(vdp, A_NORMAL | A_BOLD);
- #endif
- break;
-
- case REVERSE:
- if(window_attribute(vdp) == NORMAL)
- #if defined(__MSDOS__)
- wattrset(vdp, F_BROWN|B_GRAY);
- #else
- wattrset(vdp, A_REVERSE | A_NORMAL);
- #endif
- else
- #if defined(__MSDOS__)
- wattrset(vdp, A_HIGH|F_BROWN|B_GRAY);
- #else
- wattrset(vdp, A_REVERSE | A_BOLD);
- #endif
- break;
-
- case BLINK:
- if(window_attribute(vdp) == NORMAL)
- #if defined(__MSDOS__)
- wattrset(vdp, A_BLINK|F_BROWN|B_BLUE);
- #else
- wattrset(vdp, A_BLINK | A_NORMAL);
- #endif
- else
- #if defined(__MSDOS__)
- wattrset(vdp, A_BLINK|F_GRAY|B_BLUE);
- #else
- wattrset(vdp, A_BLINK | A_BOLD);
- #endif
- break;
- default:
- break;
- }
-
- s = temp;
- for(i=0; i< len; i++)
- *s++ = str[i];
- *s = '\0';
-
- mvwaddstr(vdp, row, col, temp);
-
- if(UPDATE_WINDOW)
- {
- wrefresh(vdp);
- wattrset(vdp, A_NORMAL);
- }
- }
-
- void create_virtual_display(num_rows, num_cols, vdid, disp_type, video_type)
- int num_rows;
- int num_cols;
- WINDOWid *vdid;
- int disp_type;
- int video_type;
- {
- /*int status;*/
- /*char temp[81];*/
- WINDOWid vdp;
- vdp = newwin(num_rows, num_cols, 0, 0);
- keypad(vdp, TRUE);
-
- if(video_type == BOLD || video_type == NORMAL) /* | --> || */
- wattrset(vdp, A_NORMAL);
- if(disp_type == BORDER)
- touchwin(vdp);
-
-
- *vdid = vdp;
- all_windows[num_windows].window_id = vdp;
- all_windows[num_windows].video_type = video_type;
- num_windows++;
- }
-
- void paste_virtual_display(vdid, row, col)
- WINDOWid vdid;
- int row;
- int col;
- {
- #if defined(unix) | defined(__MSDOS__)
- vdid->_begy = row;
- vdid->_begx = col;
- #else
- vdid->oy = row;
- vdid->ox = col;
- #endif
- touchwin(vdid);
- if(UPDATE_WINDOW)
- {
- #if defined(__MSDOS__)
- wattrset(vdid, A_NORMAL);
- box(vdid, '│', '─');
- #else
- wattrset(vdid, A_NORMAL);
- box(vdid, 0, 0);
- #endif
- wrefresh(vdid);
- }
- window_on_screen[num_window_on_screen++] = vdid;
-
- }
-
- /*
- Routine so when we are redraw something that is already on the screen
- the window_on_screen will not be added to, therefore not having duplicates
- */
- void repaste_virtual_display(vdid, row, col)
- WINDOWid vdid;
- int row;
- int col;
- {
- #if defined (unix) | defined(__MSDOS__)
- vdid->_begy = row;
- vdid->_begx = col;
- #else
- vdid->oy = row;
- vdid->ox = col;
- #endif
- touchwin(vdid);
- if(UPDATE_WINDOW)
- {
- #if defined(__MSDOS__)
- wattrset(vdid, A_NORMAL);
- box(vdid, '│', '─');
- #else
- box(vdid, 0, 0);
- #endif
- wrefresh(vdid);
- }
- }
-
- void change_virtual_display(num_rows, num_cols, vdid, disp_type, video_type)
- int num_rows;
- int num_cols;
- WINDOWid *vdid;
- int disp_type;
- int video_type;
- {
- int row,col;
- row = ((WINDOW *)(*vdid))->_begy;
- col = ((WINDOW *)(*vdid))->_begx;
- werase(*vdid);
- delwin(*vdid);
- *vdid = newwin(num_rows, num_cols, row, col);
- keypad((*vdid), TRUE);
- if(video_type == BOLD || video_type == NORMAL) /* | --> || */
- wattrset(*vdid, A_NORMAL);
- if(disp_type == BORDER)
- touchwin(*vdid);
-
- }
- void delete_virtual_display(vdid)
- WINDOWid vdid;
- {
- int i;
- werase(vdid);
- wnoutrefresh(vdid);
- delwin(vdid);
- num_window_on_screen--;
- for(i=0; i<num_window_on_screen; i++)
- {
- touchwin(window_on_screen[i]);
- wnoutrefresh(window_on_screen[i]);
- }
- doupdate();
- }
- void unpaste_virtual_display(vdid)
- WINDOWid vdid;
- {
- int i;
- werase(vdid);
- wnoutrefresh(vdid);
- num_window_on_screen--;
- for(i=0; i<num_window_on_screen; i++)
- {
- touchwin(window_on_screen[i]);
- wnoutrefresh(window_on_screen[i]);
- }
- doupdate();
- }
- void unpaste_virtual_display_only(vdid)
- WINDOWid vdid;
- {
- /*int i;*/
- werase(vdid);
- wrefresh(vdid);
- }
- void label_border(vdid, byte_string, len)
- WINDOWid vdid;
- char byte_string[];
- int len;
- {
- /*char temp[81];*/
- /*int offset;*/
- int row = 0;
- int col;
- /*int rcode;*/
- int maxx;
-
- if(window_attribute(vdid) == NORMAL)
- #if defined(__MSDOS__)
- wattrset(vdid, F_BROWN|B_GRAY);
- #else
- wattrset(vdid, A_REVERSE | A_NORMAL);
- #endif
- else
- #if defined(__MSDOS__)
- wattrset(vdid, A_HIGH | F_BROWN|B_GRAY);
- #else
- wattrset(vdid, A_REVERSE | A_BOLD);
- #endif
- #if defined (unix) | defined(__MSDOS__)
- maxx = vdid->_maxx;
- #else
- maxx = vdid->cols;
- #endif
- col = (maxx - len) / 2 + 1;
- mvwaddstr(vdid, row, col, byte_string);
- /*
- Caller must call label_border after window is pasted
- */
- wrefresh(vdid);
-
- wattrset(vdid,A_NORMAL);
- }
- void delete_pasteboard (erase_mode)
- int erase_mode;
- {
- if(erase_mode)
- {
- werase(stdscr);
- wrefresh(stdscr);
- }
- endwin();
- }
- void read_input(vdid, tcode)
- WINDOWid vdid;
- int *tcode;
- {
- int temp;
- temp = wgetch(vdid);
- *tcode = temp;
- }
- void set_cursor_abs(vdid, row, col)
- WINDOWid vdid;
- int row;
- int col;
- {
- wmove(vdid, row, col);
- if(UPDATE_WINDOW)wrefresh(vdid);
- }
- void change_rendition(vdid, row, col, num_rows, num_cols, video_type)
- WINDOWid vdid;
- int row;
- int col;
- int num_rows;
- int num_cols;
- int video_type;
- {
- int i,j;
- char temp[80];
- for(j=0; j<num_rows; j++)
- {
- for(i=0; i<num_cols; i++)
- temp[i] = mvwinch(vdid, row+j, col+i);
- temp[num_cols] = '\0';
- put_chars(vdid, temp, num_cols, row+j, col, 0, video_type);
- }
- }
- void read_display(vdid, row, s)
- WINDOWid vdid;
- int row;
- char *s;
- {
- int i /*,j*/ ;
- int maxx;
- #if defined(unix) | defined(__MSDOS__)
- maxx = vdid->_maxx;
- #else
- maxx = vdid->cols;
- #endif
-
- for(i=1; i<maxx; i++)
- *s++ = mvwinch(vdid, row, i);
- *s = '\0';
- }
- void begin_display_update(vdid)
- WINDOWid vdid;
- {
- #if defined(__MSDOS__)
- touchwin(vdid);
- #endif
- UPDATE_WINDOW = FALSE;
- }
- void end_display_update(vdid)
- WINDOWid vdid;
- {
- UPDATE_WINDOW = TRUE;
- wattrset(vdid, A_NORMAL);
- #if defined(__MSDOS__)
- box(vdid, '│', '─');
- #else
- box(vdid, 0, 0);
- #endif
- wrefresh(vdid);
- }
- void end_display_update_nobox(vdid)
- WINDOWid vdid;
- {
- UPDATE_WINDOW = TRUE;
- wattrset(vdid, A_NORMAL);
- wrefresh(vdid);
- }
- void repaint_screen()
- {
- wrefresh(curscr);
- }
- void ring_bell()
- {
- beep();
- }
- void erase_display (vdid, row, col, end_row, end_col)
- WINDOWid vdid;
- int row;
- int col;
- int end_row;
- int end_col;
- {
- char blanks[80];
- int i,j;
- wattrset(vdid, A_NORMAL);
- for(j=row; j<=end_row; j++)
- {
- for(i=col; i<=end_col; i++)
- blanks[i-col] = ' ';
- blanks[end_col-col+1] = '\0';
- mvwaddstr(vdid, j, col, blanks);
- }
- if(UPDATE_WINDOW)wrefresh(vdid);
- }
- void set_cursor_rel(vdid, num_rows, num_cols)
- WINDOWid vdid;
- int num_rows;
- int num_cols;
- {
- short curx,cury;
- #if defined(unix) | defined(__MSDOS__)
- curx = vdid->_curx;
- cury = vdid->_cury;
- #endif
- wmove(vdid, cury+num_rows, curx+num_cols);
- if(UPDATE_WINDOW)wrefresh(vdid);
- }
- void set_physical_cursor(row, col)
- int row;
- int col;
- {
- wmove(curscr, row, col);
- wrefresh(curscr);
- }
- void get_physical_cursor(row, col)
- int *row;
- int *col;
- {
- int prow, pcol;
- getyx(curscr, prow, pcol);
- *row = prow;
- *col = pcol;
- }
- void return_cursor_pos(vdid, row, col)
- WINDOWid vdid;
- int *row;
- int *col;
- {
- int vrow, vcol;
- getyx(vdid, vrow, vcol);
- *row = vrow;
- *col = vcol;
- }
- /* save_screen()
- {
- char dumpfile[60];
- sprintf(dumpfile, "/tmp/Screen.%d", getpid());
- scr_dump(dumpfile);
- werase(stdscr);
- scrollok(stdscr, TRUE);
- wrefresh(stdscr);
- }
- restore_screen()
- {
- char dumpfile[60];
- sprintf(dumpfile, "/tmp/Screen.%d", getpid());
- wrefresh(stdscr);
- scrollok(stdscr, FALSE);
- erase();
- refresh();
- scr_restore(dumpfile);
- refresh();
- unlink(dumpfile);
- } */
- #endif
-
-